<template>
  <van-nav-bar
    :title="title"
    fixed
    :right-text="rightText"
    :left-arrow="left"
    :style="{background:background}"
    @click-left="onClickLeft"
    @click-right="onClickRight"
  />
</template>
<script>
export default {
  props: {
    title: {
      type: String,
      default: '标题'
    },
    left: {
      type: Boolean,
      default: true
    },
    back: {
      type: String,
      default: '/'
    },
    rightText: {
      type: String,
      default: ''
    },
    background: {
      type: String,
      default: '#fff'
    }
  },
  methods: {
    onClickLeft() {
      this.$router.push({ path: this.back || '/' })
    },
    onClickRight() {
      this.$emit('right')
    }
  }
}
</script>
